<template>
    <!-- 提示弹窗 -->
    <uni-popup ref="popup" :mask-click="false">
        <div class="container">
            <image class="title-image" src="https://ustatic.hudongmiao.com/miao/activity/202505/hongbao5.png"
                mode="scaleToFill"></image>
            <scroll-view class="container-scroll" scroll-y enable-flex :show-scrollbar="false">
                <div class="title"><text class="title-text">抽奖说明</text></div>
                <text class="intro-text">幸运数字抽奖从4月25日至5月1日，每日8-10点、15-17点、21-23点开启，红包为随机幸运红包</text>
            </scroll-view>
            <div class="i-know" @click="close">
                <text class="text">我知道了</text>
            </div>
        </div>
    </uni-popup>
</template>

<script setup lang="ts">
const popup = ref<UniHelper.UniPopupInstance>();

/** 弹窗打开 */
const open = () => {
  if (!popup.value?.open) return;
  popup.value?.open();
};

/** 弹窗关闭 */
const close = () => {
  if (!popup.value?.close) return;
  popup.value?.close();
  emit('popupClose');
};

defineExpose({
  open,
  close,
});

const emit = defineEmits<{(event: 'clickRule'): void,
  (event: 'popupClose'): void
}>();

</script>

<style scoped lang="scss">
.container {
    position: relative;

    width: 90vw;
    max-height: 80vh;
    // transform: translateY(10vh);

    background: #FFFFFF;
    box-shadow: 0px 7 19px 0px rgba(0, 0, 0, 0.3);
    border-radius: 41rpx 41rpx 41rpx 41rpx;

    padding: 22rpx 16rpx 24rpx;

    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;

    .container-bg {
        position: absolute;
        top: 0;
        left: 0;
        z-index: -1;

        width: 100%;
        height: 100%;
    }

    .container-scroll {
        max-height: 60vh;
        width: 100%;
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
        align-items: center;

        @media (min-aspect-ratio: 330/568) {
            max-height: 400rpx;
        }
    }

    .title-image {
        position: absolute;
        top: -190rpx;
        z-index: 100;
        width: 278rpx;
        height: 210rpx;
    }

    .title {
        background-image: url("https://ustatic.hudongmiao.com/miao/activity/202505/titleBg.png");
        background-size: 565rpx 90rpx;
        width: 565rpx;
        height: 90rpx;
        display: flex;
        align-items: center;
        justify-content: center;

        .title-text {
            font-weight: 700;
            font-size: 45rpx;
            color: #FFFFFF;
            line-height: 65rpx;
            text-align: justify;
            font-style: normal;
            text-transform: none;
            margin-bottom: 10rpx;
        }
    }

    .intro-text {
        margin-top: 20rpx;
        width: 565rpx;
        font-family: Source Han Sans, Source Han Sans;
        font-weight: 400;
        font-size: 26rpx;
        color: #666666;
        line-height: 37rpx;
        text-align: justify;
        font-style: normal;
        text-transform: none;
    }

    .lottery-content {
        width: 565rpx;
        height: 653rpx;
        background-image: url("https://ustatic.hudongmiao.com/miao/activity/202505/contentBg.png");
        background-size: 100% 100%;
        background-repeat: no-repeat;
        margin-top: 20rpx;
        display: flex;
        justify-content: center;
        align-items: center;

        .lottery-items {
            width: 507rpx;
            height: 591rpx;
            background: #FFFBDD;
            border-radius: 15rpx 15rpx 15rpx 15rpx;

            display: grid;
            grid-template-columns: repeat(3, auto);
            grid-template-rows: repeat(3, auto);
            column-gap: 27rpx;
            row-gap: 9rpx;

            .lottery-item {
                display: flex;
                flex-direction: column;
                align-items: center;
                justify-content: center;

                .image {
                    width: 151rpx;
                    height: 151rpx;
                    background-color: #FFFFFF;
                }

                .text {
                    width: 151rpx;
                    height: 40rpx;
                    font-weight: 400;
                    font-size: 19rpx;
                    color: #9B642E;
                    line-height: 40rpx;
                    text-align: center;
                    font-style: normal;
                    text-transform: none;
                }
            }
        }
    }

    .i-know {
        margin-top: 20rpx;
        width: 319rpx;
        height: 95rpx;
        background-image: url("https://ustatic.hudongmiao.com/miao/activity/202505/yellowButton2.png");
        background-size: 319rpx 95rpx;
        display: flex;
        align-items: center;
        justify-content: center;

        .text {
            font-weight: 500;
            font-size: 34rpx;
            color: #FFFFFF;
            line-height: 49rpx;
            text-align: center;
            font-style: normal;
            text-transform: none;
        }
    }

}
</style>
